from time import *
file1 = open("m1_sorted.txt").readlines()
file2 = open("m2_reverse.txt").readlines()
file3 = open("m3_shuffle.txt").readlines()
mas1 = list()
mas2 = list()
mas3 = list()
for i in range(len(file1)):
    mas1.append(file1[i])
for i in range(len(file2)):
    mas2.append(file2[i])
for i in range(len(file3)):
    mas3.append(file3[i])
k = 0
start1 = time()
for i in range(len(mas1)-1):
    k = 0
    for g in range(len(mas1)-i-1):
        if mas1[g] > mas1[g+1]:
            mas1[g], mas1[g+1] = mas1[g+1], mas1[g]
            k += 1
    if k == 0:
        break
end1 = time()
print("m1_sorted", int(round(end1 - start1, 2)*1000), "milliseconds")
n = 0
start2 = time()
for i in range(len(mas2)-1):
    n = 0
    for g in range(len(mas2)-i-1):
        if mas2[g] > mas2[g+1]:
            mas2[g], mas2[g+1] = mas2[g+1], mas2[g]
            n += 1
    if n == 0:
        break
end2 = time()
print("m2_reverse", int(round(end2 - start2, 2)*1000), "milliseconds")
start3 = time()
for i in range(len(mas3)-1):
    v = 0
    for g in range(len(mas3)-i-1):
        if mas3[g] > mas3[g+1]:
            mas3[g], mas3[g+1] = mas3[g+1], mas3[g]
            v += 1
    if v == 0:
        break
end3 = time()
print("m3_shuffle", int(round(end3 - start3, 2)*1000), "milliseconds")
